package com.mexico.inloancash.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.mexico.inloancash.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 认证成功
 */
public class IndiaAuthActivity extends BaseActivity {

    @BindView(R.id.logon_back)
    ImageView gonBack;

    @BindView(R.id.title)
    TextView title;

    @BindView(R.id.to_home)
    Button mIndiaBtnHome;

    @BindView(R.id.time_end)
    TextView mIndiaTvEndTime;

    private CountDownTimer mIndiaCountDownTimer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.india_activity_auth_view_success_layout);
        ButterKnife.bind(this);
        title.setText("Certification");
        mIndiaCountDownTimer = new CountDownTimer(5000, 1000) {
            @Override
            public void onTick(long l) {
                //Regrese a la página de inicio en 5 segundos...
                mIndiaTvEndTime.setText("Return to the home page in " + l / 1000 + " seconds ...");  //设置倒计时时间
            }

            @Override
            public void onFinish() {
                Intent start = new Intent(IndiaAuthActivity.this, MainActivity.class);
                startActivity(start);
            }
        };
        mIndiaCountDownTimer.start();
    }

    @OnClick({R.id.logon_back, R.id.to_home})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.logon_back:
            case R.id.to_home:
                finish();
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (null != mIndiaCountDownTimer) {
            mIndiaCountDownTimer.cancel();
            mIndiaCountDownTimer = null;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }
}
